import { ref} from "vue";

const play = ref<(fromX: number, fromY: number, callback: () => void) => void>()

/**
 * 绑定添加购物车事件监听
 * @param action 监听到添加购物车事件后执行的操作
 */
const onAddCart = (action: (fromX: number, fromY: number, callback: () => void) => void) => {
    play.value = action
}
/**
 * 使用添加购物车特效
 * @returns 购物车特效播放方法 ：(fromX: number, fromY: number, callback: () => void) => void
 */
const useAddCartEffect: () => typeof play = () => {
    return play
}
export { useAddCartEffect, onAddCart }